package com.example.lol.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.lol.R;

import java.util.List;

public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.MyViewHolder> {


    private String[] titles = {"小蜜蜂宝典现已上线可前往客户端参加活动",
            "LPL赛后视频：369杰斯发挥亮眼 TES让1追2击败iG",
            "小蜜蜂宝典现已上线可前往客户端参加活动",
            "LPL赛后视频：369杰斯发挥亮眼 TES让1追2击败iG",
            "小蜜蜂宝典现已上线可前往客户端参加活动",
            "LPL赛后视频：369杰斯发挥亮眼 TES让1追2击败iG"};
    private String[] lol1s = {"LOL","LOL","LOL","LOL","LOL","LOL"};
    private String[] lol2s = {"英雄联盟官方","英雄联盟官方","LOL赛事咨询","英雄联盟官方","LOL赛事咨询","LOL赛事咨询"};
    private int[] readimgs = {R.drawable.home_page_middle_new_read,R.drawable.home_page_middle_new_read,R.drawable.home_page_middle_new_read,
            R.drawable.home_page_middle_new_read,R.drawable.home_page_middle_new_read,R.drawable.home_page_middle_new_read};

    private String[] reads = {"2618","1277","904","632","540","404"};
    private int[] icons = {R.drawable.icon1,R.drawable.icon2,R.drawable.icon1,
            R.drawable.icon1,R.drawable.icon2,R.drawable.icon2};




    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater
                .from(parent.getContext())
                .inflate(R.layout.home_page_middle_new,parent,false);
        MyViewHolder viewHolder  = new MyViewHolder(view);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull NewsAdapter.MyViewHolder holder, int position) {

        holder.title.setText(titles[position]);
        holder.lol1.setText(lol1s[position]);
        holder.lol2.setText(lol2s[position]);
        holder.readimg.setImageResource(readimgs[position]);
        holder.read.setText(reads[position]);
        holder.icon.setImageResource(icons[position]);

    }

    @Override
    public int getItemCount() {
        return titles.length;
    }

    public static class MyViewHolder extends RecyclerView.ViewHolder {
        private TextView title;
        private TextView lol1;
        private TextView lol2;
        private ImageView readimg;
        private TextView read;
        private ImageView icon;

        public MyViewHolder(@NonNull View itemView){
            super(itemView);

            title = itemView.findViewById(R.id.home_page_middle_new_main);
            lol1 = itemView.findViewById(R.id.home_page_middle_new_lol);
            lol2 = itemView.findViewById(R.id.home_page_middle_new_lol2);
            readimg = itemView.findViewById(R.id.home_page_middle_new_read_img);
            read = itemView.findViewById(R.id.home_page_middle_new_read);
            icon = itemView.findViewById(R.id.home_page_middle_new_img);

        }

    }


}
